package org.webdb.webapp;

import java.io.IOException;
import java.net.URL;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ClassLoaderServlet extends HttpServlet {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {

        resp.setContentType("text/plain");
        String className = req.getParameter("class");

        if (className != null) {
            URL url = this.getClass().getClassLoader()
                    .getResource(className.replace('.', '/').concat(".class"));

            resp.getWriter().println(url.toString());
            resp.getWriter().flush();
        }
    }

}
